//index.js
//获取应用实例
var app = getApp()

Page({
  data: {
    imgUrls: [
      'http://winhc.oss-cn-shanghai.aliyuncs.com/83CibQa7mh.jpg',
      'http://winhc.oss-cn-shanghai.aliyuncs.com/8QJK3nQBeC.jpg',
      'http://winhc.oss-cn-shanghai.aliyuncs.com/Xa7FwtkHRH.jpg'
    ],
    indicatorDots: false,
    autoplay: true,
    interval: 2000,
    duration: 1000,
    dataCloud1:[],
    dataCloud2:[],
    dataCloud3:[],
    dataCloud4: [],
    inputValue: '松江'
  },
  /**
   * 入口
   */
  onLoad: function () {
    this.setModule();
    this.getCloud();
    wx.showShareMenu({
      withShareTicket: true
    })
  },
  getCloud: function() {
    var _this = this;
    wx.request({
      url: 'https://route.showapi.com/9-2?showapi_sign=211bb89127d04852be4aea5ca9f0ab0e&showapi_appid=52653',
      data: {
        showapi_appid: '52653',
        showapi_sign: '211bb89127d04852be4aea5ca9f0ab0e',
        area: _this.data.inputValue
      },
      method: 'GET',
      success: function (res) {
        console.log(res.data.showapi_res_body.f1);
        if (res.data.showapi_res_body.f1.weekday == '1' || res.data.showapi_res_body.f2.weekday == '2' || res.data.showapi_res_body.f3.weekday == '3') {
          res.data.showapi_res_body.f1.weekday = "一";
          res.data.showapi_res_body.f2.weekday = '二';
          res.data.showapi_res_body.f3.weekday = '三';
        } else if (res.data.showapi_res_body.f1.weekday == '2' || res.data.showapi_res_body.f2.weekday == '3' || res.data.showapi_res_body.f3.weekday == '4') {
          res.data.showapi_res_body.f1.weekday = "二";
          res.data.showapi_res_body.f2.weekday = '三';
          res.data.showapi_res_body.f3.weekday = '四';
        } else if (res.data.showapi_res_body.f1.weekday == '3' || res.data.showapi_res_body.f2.weekday == '4' || res.data.showapi_res_body.f3.weekday == '5') {
          res.data.showapi_res_body.f1.weekday = "三";
          res.data.showapi_res_body.f2.weekday = '四';
          res.data.showapi_res_body.f3.weekday = '五';
        } else if (res.data.showapi_res_body.f1.weekday == '4' || res.data.showapi_res_body.f2.weekday == '5' || res.data.showapi_res_body.f3.weekday == '6') {
          res.data.showapi_res_body.f1.weekday = "四";
          res.data.showapi_res_body.f2.weekday = '五';
          res.data.showapi_res_body.f3.weekday = '六';
        } else if (res.data.showapi_res_body.f1.weekday == '5' || res.data.showapi_res_body.f2.weekday == '6' || res.data.showapi_res_body.f3.weekday == '7') {
          res.data.showapi_res_body.f1.weekday = "五";
          res.data.showapi_res_body.f2.weekday = '六';
          res.data.showapi_res_body.f3.weekday = '日';
        } else if (res.data.showapi_res_body.f1.weekday == '6' || res.data.showapi_res_body.f2.weekday == '7' || res.data.showapi_res_body.f3.weekday == '1') {
          res.data.showapi_res_body.f1.weekday = "六"
          res.data.showapi_res_body.f2.weekday = '日';
          res.data.showapi_res_body.f3.weekday = '一';
        } else if (res.data.showapi_res_body.f1.weekday == '7' || res.data.showapi_res_body.f2.weekday == '1' || res.data.showapi_res_body.f3.weekday == '2') {
          res.data.showapi_res_body.f1.weekday = "日"
          res.data.showapi_res_body.f2.weekday = '一';
          res.data.showapi_res_body.f3.weekday = '二';
        }
        _this.setData({
          dataCloud1: res.data.showapi_res_body.f1,
          dataCloud2: res.data.showapi_res_body.f2,
          dataCloud3: res.data.showapi_res_body.f3,
          dataCloud4: res.data.showapi_res_body.now.aqiDetail,
          // tipImg: res.data.now.weather_pic
        })
      }
    })
  },
  areaInput: function(e) {
    this.setData({
      inputValue: e.detail.value
    })
  },
  getData: function(e) {
    this.getCloud();
  },
  toidcard: function () {
    wx.navigateTo({
      url: '../idcard/idcard'
    })
  },
  tohuilv:function(){
    wx.navigateTo({
      url: '../exchangeCal/exchangeCal'
    })
  },
  /**
   * 模块入口
   */
  setModule: function(){

  },
  
  onShareAppMessage: function (res) {
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target)
    }
    return {
      title: '搜【赢火虫】',
      path: '/pages/nindex/index',
      success: function (res) {
        // 转发成功
        console.log('转发成功');
      },
      fail: function (res) {
        // 转发失败
      }
    }
  },
   
});